package com.dzl.integral.service.impl;

import com.dzl.integral.pojo.WelfareIntegralGrantDetail;
import com.dzl.integral.dao.WelfareIntegralGrantDetailMapper;
import com.dzl.integral.pojo.query.WelfareIntegralGrantDetailQuery;
import com.dzl.integral.pojo.vo.WelfareIntegralGrantDetailVo;
import com.dzl.integral.service.WelfareIntegralGrantDetailService;
import com.dzl.util.EmptyUtils;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import com.dzl.base.service.BaseServiceImpl;

import javax.annotation.Resource;
import java.util.List;

/**
 * 积分分发详情表(WelfareIntegralGrantDetail)表服务实现类
 *
 * @author caobucao
 * @date 2021-09-07 14:04:11
 */
@Service
public class WelfareIntegralGrantDetailServiceImpl extends BaseServiceImpl<WelfareIntegralGrantDetail> implements WelfareIntegralGrantDetailService {

    @Autowired
    private WelfareIntegralGrantDetailMapper mapper;

    @Override
    public List<WelfareIntegralGrantDetailVo> getIntegralGrantDetail(WelfareIntegralGrantDetailQuery query) {
        PageHelper.startPage(query);
        List<WelfareIntegralGrantDetailVo> list = mapper.selectIntegralGrantDetail(query);
        if(EmptyUtils.isNotEmpty(list)) {
            list.forEach(x -> {
                String organizationName = "";
                if(EmptyUtils.isNotEmpty(x.getFirstOrganizationName())) {
                    organizationName = organizationName + x.getFirstOrganizationName();
                }
                if(EmptyUtils.isNotEmpty(x.getSecondOrganizationName())) {
                    organizationName = organizationName + "/" + x.getSecondOrganizationName();
                }
                if(EmptyUtils.isNotEmpty(x.getThirdOrganizationName())) {
                    organizationName = organizationName + "/" + x.getThirdOrganizationName();
                }
                if(EmptyUtils.isNotEmpty(x.getFourthOrganizationName())) {
                    organizationName = organizationName + "/" + x.getFourthOrganizationName();
                }
                if(EmptyUtils.isNotEmpty(x.getFifthOrganizationName())) {
                    organizationName = organizationName + "/" + x.getFifthOrganizationName();
                }
                x.setOrganizationName(organizationName);
            });
        }
        return list;
    }
}
